import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:消减整数
 * User: wangxin
 * Date: 2024-09-29
 * Time: 10:41
 */
public class test1 {
    public static int getNum(int t){
        int n = 1;

        t = t - n;
        int count = 1;
        while(t != 0){

            if(t % 2 !=0){
                t = t - 1;
                count++;
            }else if(t % (2 * n) != 0){
                t -= n;
                count++;
            }else{
                t = t - (n * 2);
                count++;
                n *= 2;
            }

        }

        return count;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别

        int T = in.nextInt();
        while(T-- != 0){
            int t = in.nextInt();
            System.out.println(getNum(t));

        }

    }
}
